use "MASTER_DFK_FINAL.dta"

xtset ccode year

*Appendix 
***App A summary of democracy & WR linkage

***App Table 1 - Democracy indexes 

***App F1a and F1b 
*graphs showing relationship between starting point and laws
twoway (scatter legislative_areas_pos_NT v2x_gender, sort) (lowess legislative_areas_pos_NT v2x_gender, sort yaxis(2))  if gwf_democ_new==1&developing==1, ytitle("# of Legal Reforms") legend(order(1 "scatter" 2 "lowess"))
twoway (scatter legislative_areas_pos_NT v2x_gender, sort) (lowess legislative_areas_pos_NT v2x_gender, sort yaxis(2))  if gwf_autoc_new==1, ytitle("# of Legal Reforms") legend(order(1 "scatter" 2 "lowess"))

***App Table 2 - Descriptive Statistics
sum legislative_areas_pos_NT political_representation_leg econ_soc_right_leg violence_leg health_care_fgm_leg AD_total_aid_gdp_3yravg sum3_lnothercount regime_noncompelec2 logwdi_gdppc v2csreprss hist_conflict_5_fill v2x_gender cumulative_legislation_pos cedaw_rat world_legislation_dich if gwf_autoc_new==1&year>=1996&Miller_region2~=5


***App Table 3 - Removing countries that transitioned to democracy
*excluding autocs that transitioned to democ at any point
nbreg legislative_areas_pos_NT l.regime_noncompelec2  l.c.AD_total_aid_gdp_3yravg l.sum3_lnothercount  l.logwdi_gdppc  l.v2csreprss i.Miller_region2 if Miller_region2~=5&year>=1996&gwf_autoc_new==1&gwf_demtrans_ever2!=1, nolog vce(cluster ccode)
nbreg legislative_areas_pos_NT   l.c.AD_total_aid_gdp_3yravg l.sum3_lnothercount l.regime_noncompelec2  l.logwdi_gdppc l.v2csreprss hist_conflict_5_fill l.v2x_gender l.cumulative_legislation_pos l.cedaw_rat l.world_legislation_dich i.Miller_region2 if Miller_region2~=5&year>=1996&gwf_autoc_new==1&gwf_demtrans_ever2!=1, nolog vce(cluster ccode)
*rerunning main models excluding autocs that transitioned within 5 years
nbreg legislative_areas_pos_NT l.regime_noncompelec2  l.c.AD_total_aid_gdp_3yravg l.sum3_lnothercount  l.logwdi_gdppc     l.v2csreprss i.Miller_region2 if Miller_region2~=5&year>=1996&gwf_autoc_new==1&gwf_demtrans_w5!=1, nolog vce(cluster ccode)
nbreg legislative_areas_pos_NT   l.c.AD_total_aid_gdp_3yravg l.sum3_lnothercount l.regime_noncompelec2  l.logwdi_gdppc l.v2csreprss hist_conflict_5_fill l.v2x_gender l.cumulative_legislation_pos l.cedaw_rat l.world_legislation_dich i.Miller_region2 if Miller_region2~=5&year>=1996&gwf_autoc_new==1&gwf_demtrans_w5!=1, nolog vce(cluster ccode)

***App Table 4 - Heckman selection model predicting selection into dictatorship
heckman legislative_areas_pos_NT l.regime_noncompelec2  l.c.AD_total_aid_gdp_3yravg l.sum3_lnothercount  l.logwdi_gdppc     l.v2csreprss i.Miller_region2 if Miller_region2~=5&year>=1996&developing==1, select(gwf_autoc_new = region_gwf_democracy l.c.AD_total_aid_gdp_3yravg l.sum3_lnothercount  l.logwdi_gdppc l.v2csreprss i.Miller_region2) vce(cluster ccode)
 
***App Table 5 
*Note you need to use a different dataset:
use "master_6_2020_formatch2_FINAL.dta"

*treatment Aid 50th percentile
imb  regime_noncompelec2_lag1   sum3_lnothercount_lag1  logwdi_gdppc_lag1     v2csreprss_lag1 , treatment(AD_total_3yr_50)
cem  regime_noncompelec2_lag1  sum3_lnothercount_lag1 logwdi_gdppc_lag1 (#3) v2csreprss_lag1 (#3), treatment(AD_total_3yr_50)
 
nbreg legislative_areas_pos_NT l.regime_noncompelec2  l.c.AD_total_aid_gdp_3yravg l.sum3_lnothercount  l.logwdi_gdppc     l.v2csreprss  [iweight = cem_weights], nolog vce(cluster ccode)

*treatment shaming 50th percentile
imb  regime_noncompelec2_lag1   AD_total_aid_gdp_3yravg_lag1  logwdi_gdppc_lag1     v2csreprss_lag1 , treatment(sum3_3yr_50)
cem  regime_noncompelec2_lag1  AD_total_aid_gdp_3yravg_lag1 logwdi_gdppc_lag1  v2csreprss_lag1 , treatment(sum3_3yr_50)
 
nbreg legislative_areas_pos_NT l.regime_noncompelec2  l.c.AD_total_aid_gdp_3yravg l.sum3_lnothercount  l.logwdi_gdppc     l.v2csreprss  [iweight = cem_weights], nolog vce(cluster ccode)

*switch back to main master dataset
use "MASTER_DFK_FINAL.dta"
***App Table 6 - Replicating T2, models 1-2 with human trafficking in the count.
nbreg legislative_areas_pos l.regime_noncompelec2  l.c.AD_total_aid_gdp_3yravg l.sum3_lnothercount l.logwdi_gdppc l.v2csreprss i.Miller_region2 if Miller_region2~=5&year>=1996&gwf_autoc_new==1, nolog vce(cluster ccode)
nbreg legislative_areas_pos l.c.AD_total_aid_gdp_3yravg l.sum3_lnothercount l.regime_noncompelec2 l.logwdi_gdppc l.v2csreprss hist_conflict_5_fill l.v2x_gender l.cumulative_legislation_pos l.cedaw_rat l.world_legislation_dich i.Miller_region2 if Miller_region2~=5&year>=1996&gwf_autoc_new==1, nolog vce(cluster ccode)

***App Table 7 - Replicating T2, m1-2 but removing violence against women laws from the count.
nbreg legislative_areas_pos_NT_noviol l.regime_noncompelec2  l.c.AD_total_aid_gdp_3yravg l.sum3_lnothercount  l.logwdi_gdppc  l.v2csreprss i.Miller_region2 if Miller_region2~=5&year>=1996&gwf_autoc_new==1, nolog vce(cluster ccode)
nbreg legislative_areas_pos_NT_noviol   l.c.AD_total_aid_gdp_3yravg l.sum3_lnothercount l.regime_noncompelec2  l.logwdi_gdppc l.v2csreprss hist_conflict_5_fill l.v2x_gender l.cumulative_legislation_pos l.cedaw_rat l.world_legislation_dich i.Miller_region2 if Miller_region2~=5&year>=1996&gwf_autoc_new==1, nolog vce(cluster ccode)

***App Table 8 - Replicating T2, m1-2 on V-Dem women's empowerment index as DV.
reg v2x_gender l.v2x_gender l.regime_noncompelec2  l.c.AD_total_aid_gdp_3yravg l.sum3_lnothercount  l.logwdi_gdppc     l.v2csreprss i.Miller_region2 if Miller_region2~=5&year>=1996&gwf_autoc_new==1, cluster (ccode)
reg v2x_gender l.v2x_gender l.regime_noncompelec2  l.c.AD_total_aid_gdp_3yravg l.sum3_lnothercount  l.logwdi_gdppc l.v2csreprss hist_conflict_5_fill l.cumulative_legislation_pos l.cedaw_rat l.world_legislation_dich i.Miller_region2 if Miller_region2~=5&year>=1996&gwf_autoc_new==1, cluster (ccode)

***App Table 9 - Replicating Table 2 with wingos instead of shaming.  
nbreg legislative_areas_pos_NT  l.c.AD_total_aid_gdp_3yravg l.WINGO_all_years l.regime_noncompelec2  l.logwdi_gdppc  l.v2csreprss i.Miller_region2 if Miller_region2~=5&year>=1996&gwf_autoc_new==1, nolog vce(cluster ccode)
nbreg legislative_areas_pos_NT   l.c.AD_total_aid_gdp_3yravg l.WINGO_all_years l.regime_noncompelec2  l.logwdi_gdppc l.v2csreprss hist_conflict_5_fill l.v2x_gender l.cumulative_legislation_pos l.cedaw_rat l.world_legislation_dich i.Miller_region2 if Miller_region2~=5&year>=1996&gwf_autoc_new==1, nolog vce(cluster ccode)
logit econ_soc_right_leg   l.c.AD_total_aid_gdp_3yravg l.WINGO_all_years l.regime_noncompelec2 l.logwdi_gdppc l.v2csreprss hist_conflict_5_fill l.v2x_gender l.cumulative_legislation_pos l.cedaw_rat l.world_legislation_dich  i.Miller_region2 if Miller_region2~=5&year>=1996&gwf_autoc_new==1, nolog vce(cluster ccode)
logit violence_leg  l.c.AD_total_aid_gdp_3yravg l.WINGO_all_years l.regime_noncompelec2  l.logwdi_gdppc l.v2csreprss hist_conflict_5_fill l.v2x_gender l.cumulative_legislation_pos l.cedaw_rat l.world_legislation_dich  i.Miller_region2 if Miller_region2~=5&year>=1996&gwf_autoc_new==1, nolog vce(cluster ccode)
logit political_representation_leg l.c.AD_total_aid_gdp_3yravg l.WINGO_all_years l.regime_noncompelec2   l.logwdi_gdppc l.v2csreprss hist_conflict_5_fill l.v2x_gender l.cumulative_legislation_pos l.cedaw_rat l.world_legislation_dich  i.Miller_region2 if Miller_region2~=5&year>=1996&gwf_autoc_new==1, nolog vce(cluster ccode)
logit health_care_fgm_leg  l.c.AD_total_aid_gdp_3yravg l.WINGO_all_years l.regime_noncompelec2  l.logwdi_gdppc l.v2csreprss hist_conflict_5_fill l.v2x_gender l.cumulative_legislation_pos l.cedaw_rat l.world_legislation_dich  i.Miller_region2 if Miller_region2~=5&year>=1996&gwf_autoc_new==1, nolog vce(cluster ccode)

***App Table 10 - Replicating Table 2, substituting V-Dem measure for 'fiscal dependence on foreign aid' for our aid measure
nbreg legislative_areas_pos_NT  l.v2stfisccap_ord_1 l.sum3_lnothercount l.regime_noncompelec2  l.logwdi_gdppc  l.v2csreprss i.Miller_region2 if Miller_region2~=5&year>=1996&gwf_autoc_new==1, nolog vce(cluster ccode)
nbreg legislative_areas_pos_NT   l.v2stfisccap_ord_1 l.sum3_lnothercount l.regime_noncompelec2  l.logwdi_gdppc l.v2csreprss hist_conflict_5_fill l.v2x_gender l.cumulative_legislation_pos l.cedaw_rat l.world_legislation_dich i.Miller_region2 if Miller_region2~=5&year>=1996&gwf_autoc_new==1, nolog vce(cluster ccode)
*Economic & Social Equality
logit econ_soc_right_leg   l.v2stfisccap_ord_1 l.sum3_lnothercount l.regime_noncompelec2 l.logwdi_gdppc l.v2csreprss hist_conflict_5_fill l.v2x_gender l.cumulative_legislation_pos l.cedaw_rat l.world_legislation_dich  i.Miller_region2 if Miller_region2~=5&year>=1996&gwf_autoc_new==1, nolog vce(cluster ccode)
*Violence Against Women
logit violence_leg  l.v2stfisccap_ord_1 l.sum3_lnothercount l.regime_noncompelec2  l.logwdi_gdppc l.v2csreprss hist_conflict_5_fill l.v2x_gender l.cumulative_legislation_pos l.cedaw_rat l.world_legislation_dich  i.Miller_region2 if Miller_region2~=5&year>=1996&gwf_autoc_new==1, nolog vce(cluster ccode)
*Political Representation
logit political_representation_leg l.v2stfisccap_ord_1 l.sum3_lnothercount l.regime_noncompelec2   l.logwdi_gdppc l.v2csreprss hist_conflict_5_fill l.v2x_gender l.cumulative_legislation_pos l.cedaw_rat l.world_legislation_dich  i.Miller_region2 if Miller_region2~=5&year>=1996&gwf_autoc_new==1, nolog vce(cluster ccode)
*Health
logit health_care_fgm_leg  l.v2stfisccap_ord_1 l.sum3_lnothercount l.regime_noncompelec2  l.logwdi_gdppc l.v2csreprss hist_conflict_5_fill l.v2x_gender l.cumulative_legislation_pos l.cedaw_rat l.world_legislation_dich  i.Miller_region2 if Miller_region2~=5&year>=1996&gwf_autoc_new==1, nolog vce(cluster ccode)

***App Table 11 - Adding US Aid dependence to main models. Please put coeffs in same order as our main Table 2, adn with same labels. Adding US Aid dependence to main models.
nbreg legislative_areas_pos_NT  l.c.AD_total_aid_gdp_3yravg l.sum3_lnothercount l.c.AD_us_aid_gdp_3yravg l.regime_noncompelec2  l.logwdi_gdppc  l.v2csreprss i.Miller_region2 if Miller_region2~=5&year>=1996&gwf_autoc_new==1, nolog vce(cluster ccode)
nbreg legislative_areas_pos_NT   l.c.AD_total_aid_gdp_3yravg l.sum3_lnothercount l.c.AD_us_aid_gdp_3yravg l.regime_noncompelec2  l.logwdi_gdppc l.v2csreprss hist_conflict_5_fill l.v2x_gender l.cumulative_legislation_pos l.cedaw_rat l.world_legislation_dich i.Miller_region2 if Miller_region2~=5&year>=1996&gwf_autoc_new==1, nolog vce(cluster ccode)
logit econ_soc_right_leg   l.c.AD_total_aid_gdp_3yravg l.sum3_lnothercount l.c.AD_us_aid_gdp_3yravg l.regime_noncompelec2 l.logwdi_gdppc l.v2csreprss hist_conflict_5_fill l.v2x_gender l.cumulative_legislation_pos l.cedaw_rat l.world_legislation_dich  i.Miller_region2 if Miller_region2~=5&year>=1996&gwf_autoc_new==1, nolog vce(cluster ccode)
logit violence_leg  l.c.AD_total_aid_gdp_3yravg l.sum3_lnothercount l.c.AD_us_aid_gdp_3yravg l.regime_noncompelec2  l.logwdi_gdppc l.v2csreprss hist_conflict_5_fill l.v2x_gender l.cumulative_legislation_pos l.cedaw_rat l.world_legislation_dich  i.Miller_region2 if Miller_region2~=5&year>=1996&gwf_autoc_new==1, nolog vce(cluster ccode)
logit political_representation_leg l.c.AD_total_aid_gdp_3yravg l.sum3_lnothercount l.c.AD_us_aid_gdp_3yravg l.regime_noncompelec2   l.logwdi_gdppc l.v2csreprss hist_conflict_5_fill l.v2x_gender l.cumulative_legislation_pos l.cedaw_rat l.world_legislation_dich  i.Miller_region2 if Miller_region2~=5&year>=1996&gwf_autoc_new==1, nolog vce(cluster ccode)
logit health_care_fgm_leg  l.c.AD_total_aid_gdp_3yravg l.sum3_lnothercount l.c.AD_us_aid_gdp_3yravg l.regime_noncompelec2  l.logwdi_gdppc l.v2csreprss hist_conflict_5_fill l.v2x_gender l.cumulative_legislation_pos l.cedaw_rat l.world_legislation_dich  i.Miller_region2 if Miller_region2~=5&year>=1996&gwf_autoc_new==1, nolog vce(cluster ccode)

***App Table 12 - Replicating T2 (m1-2) with year FE. 
nbreg legislative_areas_pos_NT  l.c.AD_total_aid_gdp_3yravg l.sum3_lnothercount l.regime_noncompelec2  l.logwdi_gdppc  l.v2csreprss i.Miller_region2 i.year if Miller_region2~=5&year>=1996&gwf_autoc_new==1, nolog vce(cluster ccode)
nbreg legislative_areas_pos_NT   l.c.AD_total_aid_gdp_3yravg l.sum3_lnothercount l.regime_noncompelec2  l.logwdi_gdppc l.v2csreprss hist_conflict_5_fill l.v2x_gender l.cumulative_legislation_pos l.cedaw_rat l.world_legislation_dich i.Miller_region2 i.year if Miller_region2~=5&year>=1996&gwf_autoc_new==1, nolog vce(cluster ccode)

***App Table 13 - Replicating T2 excluding comm and post-comm dictatorships. 
nbreg legislative_areas_pos_NT  l.c.AD_total_aid_gdp_3yravg l.sum3_lnothercount l.regime_noncompelec2  l.logwdi_gdppc  l.v2csreprss i.Miller_region2 if Miller_region2~=5&year>=1996&gwf_autoc_new==1&comm!=1, nolog vce(cluster ccode)
nbreg legislative_areas_pos_NT   l.c.AD_total_aid_gdp_3yravg l.sum3_lnothercount l.regime_noncompelec2  l.logwdi_gdppc l.v2csreprss hist_conflict_5_fill l.v2x_gender l.cumulative_legislation_pos l.cedaw_rat l.world_legislation_dich i.Miller_region2 if Miller_region2~=5&year>=1996&gwf_autoc_new==1&comm!=1, nolog vce(cluster ccode)
logit econ_soc_right_leg   l.c.AD_total_aid_gdp_3yravg l.sum3_lnothercount l.regime_noncompelec2 l.logwdi_gdppc l.v2csreprss hist_conflict_5_fill l.v2x_gender l.cumulative_legislation_pos l.cedaw_rat l.world_legislation_dich  i.Miller_region2 if Miller_region2~=5&year>=1996&gwf_autoc_new==1&comm!=1, nolog vce(cluster ccode)
logit violence_leg  l.c.AD_total_aid_gdp_3yravg l.sum3_lnothercount l.regime_noncompelec2  l.logwdi_gdppc l.v2csreprss hist_conflict_5_fill l.v2x_gender l.cumulative_legislation_pos l.cedaw_rat l.world_legislation_dich  i.Miller_region2 if Miller_region2~=5&year>=1996&gwf_autoc_new==1&comm!=1, nolog vce(cluster ccode)
logit political_representation_leg l.c.AD_total_aid_gdp_3yravg l.sum3_lnothercount l.regime_noncompelec2   l.logwdi_gdppc l.v2csreprss hist_conflict_5_fill l.v2x_gender l.cumulative_legislation_pos l.cedaw_rat l.world_legislation_dich  i.Miller_region2 if Miller_region2~=5&year>=1996&gwf_autoc_new==1&comm!=1, nolog vce(cluster ccode)
logit health_care_fgm_leg  l.c.AD_total_aid_gdp_3yravg l.sum3_lnothercount l.regime_noncompelec2  l.logwdi_gdppc l.v2csreprss hist_conflict_5_fill l.v2x_gender l.cumulative_legislation_pos l.cedaw_rat l.world_legislation_dich  i.Miller_region2 if Miller_region2~=5&year>=1996&gwf_autoc_new==1&comm!=1, nolog vce(cluster ccode)

***App Table 14 - Replicating T2 excluding 5-year post conflict period. 
nbreg legislative_areas_pos_NT  l.c.AD_total_aid_gdp_3yravg l.sum3_lnothercount l.regime_noncompelec2  l.logwdi_gdppc  l.v2csreprss i.Miller_region2 if Miller_region2~=5&year>=1996&gwf_autoc_new==1&hist_conflict_5_fill!=1, nolog vce(cluster ccode)
nbreg legislative_areas_pos_NT   l.c.AD_total_aid_gdp_3yravg l.sum3_lnothercount l.regime_noncompelec2  l.logwdi_gdppc l.v2csreprss hist_conflict_5_fill l.v2x_gender l.cumulative_legislation_pos l.cedaw_rat l.world_legislation_dich i.Miller_region2 if Miller_region2~=5&year>=1996&gwf_autoc_new==1&hist_conflict_5_fill!=1, nolog vce(cluster ccode)
logit econ_soc_right_leg   l.c.AD_total_aid_gdp_3yravg l.sum3_lnothercount l.regime_noncompelec2 l.logwdi_gdppc l.v2csreprss hist_conflict_5_fill l.v2x_gender l.cumulative_legislation_pos l.cedaw_rat l.world_legislation_dich  i.Miller_region2 if Miller_region2~=5&year>=1996&gwf_autoc_new==1&hist_conflict_5_fill!=1, nolog vce(cluster ccode)
logit violence_leg  l.c.AD_total_aid_gdp_3yravg l.sum3_lnothercount l.regime_noncompelec2  l.logwdi_gdppc l.v2csreprss hist_conflict_5_fill l.v2x_gender l.cumulative_legislation_pos l.cedaw_rat l.world_legislation_dich  i.Miller_region2 if Miller_region2~=5&year>=1996&gwf_autoc_new==1&hist_conflict_5_fill!=1, nolog vce(cluster ccode)
logit political_representation_leg l.c.AD_total_aid_gdp_3yravg l.sum3_lnothercount l.regime_noncompelec2   l.logwdi_gdppc l.v2csreprss hist_conflict_5_fill l.v2x_gender l.cumulative_legislation_pos l.cedaw_rat l.world_legislation_dich  i.Miller_region2 if Miller_region2~=5&year>=1996&gwf_autoc_new==1&hist_conflict_5_fill!=1, nolog vce(cluster ccode)
logit health_care_fgm_leg  l.c.AD_total_aid_gdp_3yravg l.sum3_lnothercount l.regime_noncompelec2  l.logwdi_gdppc l.v2csreprss hist_conflict_5_fill l.v2x_gender l.cumulative_legislation_pos l.cedaw_rat l.world_legislation_dich  i.Miller_region2 if Miller_region2~=5&year>=1996&gwf_autoc_new==1&hist_conflict_5_fill!=1, nolog vce(cluster ccode)
